// 定义表格列对象，对象属性为tableItem类型
interface TableObj {
  [params: string]: TableItem[]
}

// 定义表格对象列属性类型
interface TableItem {
  type?: string
  prop?: string
  label?: string
  align?: string
  minWidth?: string | number
  width?: string | number
  slotName?: string
  headerSlot?: string
  isNoShowColumn?: boolean
}

// 默认表格头部内容,格列标识
const tableObj: TableObj = {
  default: [
    {
      type: 'selection',
      width: 55,
    },
    {
      prop: 'name',
      label: '名称',
      align: 'center',
      minWidth: '180',
    },
    {
      prop: 'address',
      label: '地址',
      align: 'center',
      minWidth: '200',
    },
    {
      prop: 'typeLabel',
      label: '调查对象分类',
      align: 'center',
      width: '220',
    },
    {
      prop: 'createBy',
      label: '创建人',
      align: 'center',
      width: '180',
    },
    {
      prop: 'updateTime',
      label: '更新时间',
      align: 'center',
      width: '180',
      slotName: 'updateTime',
    },
    {
      label: '操作',
      align: 'center',
      width: '180',
      slotName: 'caozuo',
    },
  ],
  tableone: [
    {
      type: 'selection',
      width: 55,
    },
    {
      prop: 'name',
      label: '名称',
      align: 'center',
      minWidth: '180',
    },
    {
      prop: 'role',
      label: '角色',
      align: 'center',
      minWidth: '200',
    },
    {
      prop: 'age',
      label: '年级',
      align: 'center',
      width: '220',
    },
    {
      prop: 'weight',
      label: '体重',
      align: 'center',
      width: '180',
    },
    {
      prop: 'createTime',
      label: '创建时间',
      align: 'center',
      width: '180',
      slotName: 'createTime',
    },
    {
      label: '操作',
      align: 'center',
      width: '180',
      slotName: 'caozuo',
    },
  ],
}

// 获取表格头部内容
export const getTableColumnList = (typeLabel: string) => {
  let name = '默认'
  for (const i in tableObj) {
    // 判断表头信息的标识并修改
    if (i.indexOf(typeLabel) !== -1) {
      name = i
      break
    }
  }
  const list = tableObj[name] // 匹配表个列数据
  return list
}
